package model.parser;

import util.resources.ResourceManager;


/**
 * Represents an exceptional situation specific to this project.
 * 
 * @author Robert C. Duvall
 * @author KevinWang Chris James Misha Lavrov
 */
@SuppressWarnings("serial")
public class ParserException extends RuntimeException
{
    public static ParserException bad_token(String token)
    {
        return new ParserException(exceptionText("bad_token")+token);
    }

    /*
     * All these static classes are used to allow consistent exceptions.
     */
    public static ParserException BAD_ARGUMENTS =
        new ParserException(exceptionText("bad_arguments"));
    
    public static ParserException TURTLE_EXIST =
        new ParserException(exceptionText("turtle_exist"));
    
    public static ParserException TAB_NOT_EXIST =
        new ParserException(exceptionText("tab_not_exist"));


    public static ParserException BAD_SYNTAX =
        new ParserException(exceptionText("bad_syntax"));
    
    public static ParserException BAD_REFLECTION =
        new ParserException(exceptionText("bad_reflection"));
    
    public static ParserException BAD_VARIABLE =
        new ParserException(exceptionText("var does not exist"));
    
    public static ParserException bad_lvalue(String lvalue)
    {
        return new ParserException(exceptionText("bad_lvalue")+lvalue);
    }
    
    public static ParserException INTERNAL_ERROR =
        new ParserException(exceptionText("internal_error"));

    private static String exceptionText(String key)
    {
        ResourceManager rm = ResourceManager.getInstance();
        rm.addResourcesFromFile("error");
        
        return rm.getString(key);
    }
    
    /**
     * Create exception with given message
     *  
     * @param message explanation of problem
     */
    public ParserException (String message)
    {
        super(message);
    }
}
